package models;

import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.OneToMany;

import play.db.jpa.Model;

@Entity
public class Timeline extends Model {

	public ActionPlan actionPlan;
	
	@OneToMany(mappedBy = "timeline", cascade = CascadeType.ALL)
	public List<Comment> comments = new ArrayList<Comment>();

	public void delete2() {
               // delete all the comments in it
               while(!comments.isEmpty()){
                       comments.get(0).delete2();
               }

               Log log = new Log("^ is deleted.");
               log.ids = this.id + "";
               log.types = "timeline";
               log.save();
               this.delete();
       }

}
